<link href="<@sp.static/>/assets/plugins/jquery-file-upload/css/jquery.fileupload.css" rel="stylesheet" />
<link href="<@sp.static/>/assets/plugins/jquery-file-upload/css/jquery.fileupload-ui.css" rel="stylesheet" />
<h1 class="page-header">
    <small>发券记录</small>
</h1>
<hr/>
<div class="panel panel-inverse" data-sortable-id="form-stuff-5">
    <div class="panel-heading">
        <h4 class="panel-title">发券记录</h4>
    </div>
    <div class="panel-body">
        <form id="activityGroupForm" name="activityGroupForm" method="post" class="form-inline">
            <input type="hidden" id="EQ_type" name="EQ_type" value="1"/>
            <div class="block clearfix" style="display: block;height: 45px;">
                <div class="form-group m-r-10">
                        <input type="text" placeholder="操作人" class="form-control" id="EQ_operator" name="EQ_operator">
                </div>
                <div class="form-group m-r-10">
                        <input type="text" placeholder="用户ID" class="form-control" id="EQ_userId" name="EQ_userId">
                </div>
                <div class="form-group m-r-10">
                        <input type="text" placeholder="分组ID" class="form-control" id="EQ_groupId" name="EQ_groupId">
                </div>
            </div>
            <div class="block clearfix" style="display: block">
                <div class="form-group m-r-10">
                        <input type="text" placeholder="批量发券Excel名称" class="form-control" id="LIKE_fileName" name="LIKE_fileName">
                </div>
                <div class="form-group m-r-10">
                    <button type="button"
                            class="btn btn-success btn-sm"
                            onclick="postDataByForm('${rc.contextPath}/backend/sendLog/queryList','activityGroupList','activityGroupForm')">
                        <i class="fa fa-search"></i>查询
                    </button>
                    <button type="button" class="btn btn-success btn-sm" onclick="exportExcel();">
                        <i class="fa fa-sign-out"></i>导出Excel
                    </button>
                    &nbsp;<span style="color: red;">(一次导出表格不可超过50000条，否则可能导致出错哦)</span>
                </div>
            </div>
        </form>
    </div>
</div>
<div id="activityGroupList"></div>
<script type="application/javascript">
    $(function () {
        postDataByForm('${rc.contextPath}/backend/sendLog/queryList', 'activityGroupList', 'activityGroupForm');
    });

    function sendLogTab(type) {
        if (type == '1') {
            $('#EQ_type').val(1);
        } else {
            $('#EQ_type').val(2);
        }

        postDataByForm('${rc.contextPath}/backend/sendLog/queryList', 'activityGroupList', 'activityGroupForm');
    }

    function removeUserCoupon(id) {
        var html = '<div><p>确定作废该次记录发放的所有卡券？</p>'+
                    '<p>注意：</p>'+
                    '<p>1、已使用、已过期的卡券无法作废。</p>'+
                    '<p>2、该操作不可逆。</p>'+
                    '</div>';
        layer.confirm(html, {
            btn: ['确定']
        }, function () {
            $.ajax({
                type: "GET",
                url: "${rc.contextPath}/backend/couponGroup/removeUserCoupon/" + id,
                success: function (data) {
                    if (data.result) {
                        $.close();

                        layer.confirm('<p>作废操作成功！</p>', {
                            btn: ['确定']
                        }, function () {
                            $.close();
                            postDataByForm('${rc.contextPath}/backend/sendLog/queryList', 'activityGroupList', 'activityGroupForm');
                        });
                    }
                }
            })
        });
    }

    function exportExcel() {
        var params = "EQ_type="+$("#EQ_type").val()+"&EQ_operator="+$("#EQ_operator").val()+"&EQ_userId="+$("#EQ_userId").val()+"&EQ_groupId="+$("#EQ_groupId").val()+"&LIKE_fileName="+$("#LIKE_fileName").val();
        window.open( "${rc.contextPath}/backend/sendLog/export?" + params, "_blank");
        $.close();
    }
</script>